import { Controller } from 'egg';

export default class AppConfigController extends Controller {
  /**
   * 刷新配置
   */
  public async refresh () {
    const { app, ctx } = this;
    try {
      ctx.logger.info('get refresh config request from', ctx.ip);
      app.messenger.sendToApp('refresh_config', ctx.ip);

      ctx.result.message = '广播刷新配置到所有进程成功';
      ctx.sendSuccess();
    } catch (e) {
      ctx.logger.error('刷新配置失败', e);

      ctx.sendError('刷新配置失败');
    }
  }
}
